/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 */

#include <rthw.h>
#include <rtconfig.h>
#include "ACM32Fxx_HAL.h"
extern LPUART_HandleTypeDef LPUART_handler;
extern UART_HandleTypeDef UART2_Handle;

#ifndef RT_USING_FINSH
#error Please uncomment the line <#include "finsh_config.h"> in the rtconfig.h
#endif

#ifdef RT_USING_FINSH

RT_WEAK char rt_hw_console_getchar(void)
{
	/* Note: the initial value of ch must < 0 */

	char ch = -1;

	HAL_LPUART_Receive_Bytes_Timeout(&LPUART_handler, (unsigned char *)&ch, 1, 10);
	//HAL_LPUART_Receive_Bytes(&LPUART_handler, (unsigned char *)&ch, 1);
	//HAL_UART_Receive(&UART2_Handle, (unsigned char *)&ch, 1, 10);

	return ch;
}

#endif /* RT_USING_FINSH */
